package com.mobilesales.android.util;

import java.lang.Thread.UncaughtExceptionHandler;

import com.mobilesales.android.R;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class ExceptionHandler implements UncaughtExceptionHandler {

	private Context context;

	public ExceptionHandler(Context ctx) {
		this.context = ctx;
	}

	public void uncaughtException(Thread thread, Throwable ex) {
		AlertDialog.Builder builder = new AlertDialog.Builder(context)
			.setTitle(context.getString(R.string.Error))
			.setMessage(context.getString(R.string.ErrorUnknown))
			.setPositiveButton("OK", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int id) {
				dialog.cancel();
			}
		});
		builder.create().show();
	}

}
